用 Spire.XLS for Java工具 把Excel文件转为pdf文件 |
您所在的位置:网站首页 › java xls转pdf › 用 Spire.XLS for Java工具 把Excel文件转为pdf文件 |
用Spire工具 把Excel文件转为pdf文件并保存 参考Java 将Excel转为PDF 帮助文档 文档转换 Java 将 Excel 转为 PDF 1.添加jar包 或者 添加依赖 2.把C:/TEST/test.xlsx文件 转为为C:/TEST/test.pdf文件 import com.spire.xls.FileFormat; import com.spire.xls.Workbook; public class ExcelToPdf { public static void main(String[] args) { String newFilePath = "C:/TEST/test.xlsx"; String newPDFPath = "C:/TEST/test.pdf"; excelToPdf(newFilePath, newPDFPath); } public static void excelToPdf(String excelPath, String pdfPath) { // load excel file Workbook wb = new Workbook(); wb.loadFromFile(excelPath); // convert excel file to pdf file wb.saveToFile(pdfPath, FileFormat.PDF); } }
下载包 地址Free Spire.XLS for Java 下载后 把Spire.Xls-FE_2.2.0.zip 解压。然后在Spire.Xls-FE_2.2.0\lib文件下找到 Spire.Xls.jar包,把Spire.Xls.jar复制到你自己的项目。就可以用了。
|
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |